package java.com.ktjy.factory;

import com.ktjy.dao.NewsDao;
import java.com.ktjy.dao.impl.NewsDaoImpl;
import java.com.ktjy.dao.impl.NewsDaoMysqlImpl;

public class SimpleDaoFactory {
    public static NewsDao getInstance(String key){
//        return new NewsDaoImpl();
        switch (key){
            case "mysql":
                return new NewsDaoMysqlImpl();
            case "oracle":
                return new NewsDaoImpl();
            case "redis":
                return new NewsDaoImpl();
            default:
                throw new RuntimeException("无效的数据库类型:"+key+",DAO获取失败");
        }
    }
}
